package com.henvc.doudizhu;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

public class JokerSystem {
	private ArrayList<String> colors = new ArrayList<>();
	private ArrayList<String> numbers = new ArrayList<>();

	private Map<Integer, String> cardsMap = new HashMap<Integer, String>();
	private ArrayList<Integer> cards = new ArrayList<>();

	private ArrayList<Integer> player1 = new ArrayList();
	private ArrayList<Integer> player2 = new ArrayList();
	private ArrayList<Integer> player3 = new ArrayList();
	private ArrayList<Integer> secret = new ArrayList();

	public void initData() {
		colors.add("黑");
		colors.add("红");
		colors.add("梅");
		colors.add("方");

		// 准备扑克牌
		for (int i = 3; i <= 10; i++) {
			numbers.add(i + "");
		}
		numbers.add("J");
		numbers.add("Q");
		numbers.add("K");
		numbers.add("A");
		numbers.add("2");
		int index = 0;
		for (String color : colors) {
			for (String number : numbers) {
				cardsMap.put(index++, color + number);
			}
		}
		cardsMap.put(index++, "小王");
		cardsMap.put(index, "小王");

		// 初始化牌的书顺序
		for (int i = 0; i < 53; i++) {
			cards.add(i);
		}
	}

	public void randomCards() {
		Collections.shuffle(cards);
	}

	// 发牌
	public void go() {
		for (int i = 0; i < cards.size()-3; i++) {
			switch (i % 3) {
				case 0:
					player1.add(cards.get(i));
					break;
				case 1:
					player2.add(cards.get(i));
					break;
				case 2:
					player3.add(cards.get(i));
			}
		}
		secret.add(cards.get(50));
		secret.add(cards.get(51));
		secret.add(cards.get(52));
	}
	//显示
	public void show(){
		System.out.println("Player1");
		showCards(player1);
		System.out.println("Player2");
		showCards(player2);
		System.out.println("Player3");
		showCards(player3);
		System.out.println("secret");
		showCards(secret);
	}

	private void showCards(ArrayList<Integer> list) {
		// TODO Auto-generated method stub
		for(Integer index:list){
			System.out.print(cardsMap.get(index) +" ");
		}
		System.out.println();
	}

}
